package net.qiqbframework.modelling.repository;

import lombok.Getter;
import lombok.Setter;

import java.util.Objects;

/**
 *
 */
@Getter
public class AggregateBizIdentifierVoucher {

    /**
     * 业务ID 名称
     */
    private final String bizIdentifierName;
    /**
     * 业务ID实际数据
     */
    private final Object bizIdentifier;


    public AggregateBizIdentifierVoucher(String bizIdentifierName, Object bizIdentifier) {
        this.bizIdentifierName = bizIdentifierName;
        this.bizIdentifier = bizIdentifier;
    }

    public String getKey() {
        return bizIdentifierName + ":" + bizIdentifier;
    }

    @Override
    public String toString() {
        return "BizIdentifierVoucher{" +
                "bizIdentifier=" + bizIdentifier +
                ", bizIdentifierName='" + bizIdentifierName + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        AggregateBizIdentifierVoucher that = (AggregateBizIdentifierVoucher) o;
        return Objects.equals(bizIdentifierName, that.bizIdentifierName) && Objects.equals(bizIdentifier, that.bizIdentifier);
    }

    @Override
    public int hashCode() {
        int result = Objects.hashCode(bizIdentifierName);
        result = 31 * result + Objects.hashCode(bizIdentifier);
        return result;
    }
}
